package love.lkzy.oj.codeSandBox;


import cn.hutool.core.io.resource.ResourceUtil;
import love.lkzy.oj.codeSandBox.model.ExecuteCodeRequest;
import love.lkzy.oj.codeSandBox.model.ExecuteCodeResponse;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

@SpringBootTest
public class TempTest {


    @Resource
    private ICodeSandBox codeSandBox;

    @Test
    void temp() {
        System.out.println("**********开始执行**********");

        //System.out.println("结果:" + iCodeSandBox.executeCode(null).toString());

        // 从Resource中读取代码字符串
        ExecuteCodeRequest executeCodeRequest = new ExecuteCodeRequest();
        String code = ResourceUtil.readStr("testCodeDir"+ File.separator+"Main.java", StandardCharsets.UTF_8);
        executeCodeRequest.setCode(code);
        executeCodeRequest.setLanguage("JAVA");
        executeCodeRequest.setInputList(Arrays.asList("1 2", "3 97"));
        ExecuteCodeResponse res = codeSandBox.executeCode(executeCodeRequest);
        System.out.println("执行结果:" + res);
        System.out.println("**********结束程序**********");
    }


}
